package com.joesem.sale.client.logic.workOrder.option.viewModel

import android.app.Application
import android.util.Log
import com.joesem.sale.client.base.BaseViewModel
import com.joesem.sale.client.base.request
import com.joesem.sale.client.base.toast
import com.joesem.sale.client.network.data.ProductMode

class ProductViewModel(application: Application) : BaseViewModel(application) {
    fun getProductList(customerId: String? = null, isFirstPage: Boolean) {
        request(request = {
            getProductsList(customerId, isFirstPage)
        }, response = {
            actionIntent(ListIntent(it.data?.filterNotNull() ?: arrayListOf(), isFirstPage))
        }, responseFailed = {
            toast(it.message)
            actionIntent(ListIntent(arrayListOf(), isFirstPage))
        })

    }

    class ListIntent(val data: List<ProductMode>, val isFirst: Boolean)
}